import java.io.IOException;
import java.util.TreeMap;

import org.apache.http.client.ClientProtocolException;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bootdo.common.utils.HttpUtil;
import com.bootdo.common.wx.WeiXinUtil;

public class TuwenUpload {
	
	public static void main(String[] args) throws Exception {
		String access_token =WeiXinUtil.getOauth2AccessToken2("wxcb74c2a7fb1fd161",  "3ba771e951e1e0e917b7dcd777a25e06");
//		System.out.println(access_token);
//		String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token="+access_token;
		//永久素材地址
		String url = "https://api.weixin.qq.com/cgi-bin/material/add_material?type=thumb&access_token="+access_token;
		
//        JSONObject json1=new JSONObject();
//        JSONObject json2=new JSONObject();
//        json2.put("title","图文测试66666");
//        json2.put("thumb_media_id","Wr8SVx7Dgzgll4I2-xlgj0d9BsheOXyPAXm4XQzPhCs");
//        json2.put("show_cover_pic","1");
//        json2.put("content","测试内容666666");
//        JSONArray jsonArray=new JSONArray();
//        jsonArray.add(json2);
//        json1.put("articles",jsonArray);
		
		Tuwen tt = new Tuwen();
		tt.setTitle("图文测试66666");
		tt.setThumb_media_id("Wr8SVx7Dgzgll4I2-xlgj0d9BsheOXyPAXm4XQzPhCs");
		tt.setContent("测试内容666666");
		tt.setDigest("描述666666");
		tt.setShow_cover_pic(1);
		
		JSONObject json = (JSONObject) JSONObject.toJSON(tt);
		String str = json.toString();
		str = "{"+"\"articles\":["+str+"]"+"}";
		System.out.println(str);
		JSONObject result = HttpsUtil2.httpsRequest(url, "POST", str);
		System.out.println(result);
	}

}
